const {
  findPbNews,
  findANew,
  findLimitNews,
} = require("../../services/web/news.service");

class NewsController {
  async findAllPb(ctx) {
    const res = await findPbNews();

    if (res) {
      ctx.body = {
        code: 0,
        message: "获取新闻列表成功",
        result: res,
      };
    }
  }

  async findOne(ctx) {
    const res = await findANew({ id: ctx.params.id });
    if (res) {
      ctx.body = {
        code: 0,
        message: "获取新闻信息成功",
        result: res,
      };
    }
  }

  async findLimit(ctx) {
    const res = await findLimitNews({ limit: ctx.query.limit });
    if (res) {
      ctx.body = {
        code: 0,
        message: "获取top新闻信息成功",
        result: res,
      };
    }
  }
}

module.exports = new NewsController();
